function Swiper(el){
    this.el=document.querySelector(el)
   
    this.num=1
    this.t = null
    this.init()
}
Swiper.prototype.init=function(){
    this.start()
    this.endPlay()
}
//封装图片1S改变一次方法
Swiper.prototype.changeImg=function(num){
    this.el.querySelector('img').src=`./imgs/img${num}.jpg`
    this.el.querySelector('ul li.active').className=''
    this.el.querySelector(`ul li:nth-of-type(${num})`).className='active'
}
//计时器方法
Swiper.prototype.start=function(){
    this.t = setInterval(()=>{
        this.num++
        if(this.num==7) this.num=1 
        this.changeImg(this.num)
    },1000)
}
//操作li停止计时器
Swiper.prototype.endPlay=function(){
    this.el.querySelectorAll('ul li').forEach((item,i)=>{
        item.onmouseover= () =>{
            clearInterval(this.t)
            this.changeImg(i+1)
            this.num=i+1
        }
        item.onmouseout=()=>{
            this.start()
        }
    })
}
export default Swiper;